package com.example.aigc_education.controller.common;

import com.example.aigc_education.integration.threeparty.AliYunService;
import com.example.aigc_education.utils.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@Slf4j
@RequestMapping("/file")
@RestController
public class FileController {

    @Autowired
    private AliYunService aliYunService;


    /**
     * 图片上传
     * @param image 图片
     * @return
     */
    @PostMapping("/uploadImage")
    public ResultUtil uploadImage(@RequestParam("image") MultipartFile image) {
        return aliYunService.uploadImage(image);
    }

    /**
     * 文档上传
     * @param document 文档
     * @return
     */
    @PostMapping("/uploadDocument")
    public ResultUtil uploadDocument(@RequestParam("document") MultipartFile document) {
        return aliYunService.uploadDocument(document);
    }
}
